package mylab.usm.oauth2.client.config;

import cn.hutool.core.lang.Assert;
import com.fujieid.jap.core.config.JapConfig;
import com.fujieid.jap.sso.config.JapSsoConfig;
import lombok.experimental.UtilityClass;

/**
 * 公共配置
 *
 * @author yadong.zhang (yadong.zhang0415(a)gmail.com)
 * @version 1.0.0
 * @date 2021-01-21 10:32
 * @since 1.0.0
 */
@UtilityClass
public class JapConfigContext {

    public boolean sso = true;
    public String domain;
    public String strategy;

    public JapConfig getConfig() {
        Assert.notEmpty(domain, "应用未配置域名");
        String cookieName = domain.replace(".", "_") + "_sso_id";
        return new JapConfig()
                .setSso(sso)
                .setSsoConfig(new JapSsoConfig()
                        .setCookieName(cookieName)
                        .setCookieDomain(domain));
    }
}
